import os
import sys
import django

base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(base_dir)
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'pawnshop.settings')
django.setup()
import datetime
from api import models


def init_data():
    auction_obj = models.Auction.objects.create(
        status=2,
        title='茅台专场',
        cover='19803630852-1645846574-1305448189.cos.ap-chengdu.myqcloud.com/ztpl36ur1645969425522.png',
        preview_start_time=datetime.datetime.now() - datetime.timedelta(hours=4),
        preview_end_time=datetime.datetime.now(),
        auction_start_time=datetime.datetime.now(),
        auction_end_time=datetime.datetime.now() + datetime.timedelta(hours=4),
        deposit=1200,
    )
    auction_item_obj = models.AuctionItem.objects.create(
        auction=auction_obj,
        uid='2232918',
        status=2,
        title='遁地',
        cover='19803630852-1645846574-1305448189.cos.ap-chengdu.myqcloud.com/ztpl36ur1645969425522.png',
        start_price=1000,
        deal_price=2800,
        reserve_price=1000,
        highest_price=3200,
    )
    models.AuctionItemImage.objects.create(
        item=auction_item_obj,
        img='19803630852-1645846574-1305448189.cos.ap-chengdu.myqcloud.com/ztpl36ur1645969425522.png',
        carousel=True,
        order=1
    )
    models.AuctionItemImage.objects.create(
        item=auction_item_obj,
        img='19803630852-1645846574-1305448189.cos.ap-chengdu.myqcloud.com/ztpl36ur1645969425522.png',
        carousel=True,
        order=2
    )
    models.AuctionItemDetail.objects.create(
        item=auction_item_obj,
        key='符号',
        value='1879年份'
    )


if __name__ == '__main__':
    init_data()
